using MicroMsg.Plugin.Sns.Scene;
using MicroMsg.Storage;
using MicroMsg.UI.Util;
using Microsoft.Phone.Controls;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace MicroMsg.UI.UserContrl
{
	public class ScrollPicItem : SnsHttpImgCtrlBase
	{
		public delegate void ListItemClick(object sender, object object_0);
		private const string TAG = "ScrollPicItem";
		private const SolidColorBrush cBrushCoverNormal = null;
		public Rect mRect = default(Rect);
		public BitmapImage mImgThumb;
		public int mNPicIndex = -1;
		private static SolidColorBrush cBrushCoverTouch;
		private bool mBIsClickCancled;
		internal Grid girdLayout;
		internal Image imgContent;
		internal PerformanceProgressBar progressBar;
		private bool _contentLoaded;
		public event ScrollPicItem.ListItemClick ItemClick;
		public ScrollPicItem()
		{
			this.InitializeComponent();
		}
		protected override void ObjectCome(object object_0)
		{
			this.hideProcess();
			if (object_0 != null && object_0 is snsMediaDownloadInfo)
			{
				snsMediaDownloadInfo snsMediaDownloadInfo = object_0 as snsMediaDownloadInfo;
				if (snsMediaDownloadInfo.object_0 != null && snsMediaDownloadInfo.object_0 is BitmapImage)
				{
					BitmapImage source = snsMediaDownloadInfo.object_0 as BitmapImage;
					this.imgContent.set_Source(source);
				}
				return;
			}
		}
		protected override void MediaInfoChanged(TloMedia mediaInfo)
		{
			this.hideProcess();
			this.imgContent.set_Source(null);
			if (base.ObjMediaInfo == null)
			{
				base.StopRequest();
				return;
			}
			this.mRect = ToolFunction.GetImageFillModeRect(new Size(480.0, 800.0), new Size((double)mediaInfo.nWidth, (double)mediaInfo.nHeight));
			this.imgContent.set_Width(480.0);
			this.imgContent.set_Height(800.0);
			snsMediaDownloadInfo snsMediaDownloadInfo = new snsMediaDownloadInfo
			{
				snsObjID = base.ObjMediaInfo.nID,
				string_0 = base.ObjMediaInfo.strUrl,
				urlType = (SnsUrlType)base.ObjMediaInfo.nUrlType,
				priority = SnsPriority.HIGH
			};
			base.StartRequest(snsMediaDownloadInfo, true);
			if (snsMediaDownloadInfo.object_0 == null)
			{
				this.showProcess();
				if (this.mImgThumb != null)
				{
					this.imgContent.set_Source(this.mImgThumb);
				}
			}
		}
		public void SetThumb(BitmapImage bitmapImage_0)
		{
			this.mImgThumb = bitmapImage_0;
		}
		private void btnLayoutRoot_Click(object sender, RoutedEventArgs e)
		{
			this.clicked();
		}
		private void clicked()
		{
		}
		private void showProcess()
		{
			this.progressBar.set_Visibility(0);
			this.progressBar.IsIndeterminate = true;
		}
		private void hideProcess()
		{
			this.progressBar.set_Visibility(1);
			this.progressBar.IsIndeterminate = false;
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/Sns/Circle/UI/ScrollPicItem.xaml", 2));
			this.girdLayout = (Grid)base.FindName("girdLayout");
			this.imgContent = (Image)base.FindName("imgContent");
			this.progressBar = (PerformanceProgressBar)base.FindName("progressBar");
		}
		static ScrollPicItem()
		{
			// Note: this type is marked as 'beforefieldinit'.
			SolidColorBrush solidColorBrush = new SolidColorBrush();
			solidColorBrush.set_Color(Color.FromArgb(153, 0, 0, 0));
			ScrollPicItem.cBrushCoverTouch = solidColorBrush;
		}
	}
}
